package net.dlz.example.service;

import net.dlz.example.domain.District;
import net.dlz.example.domain.DistrictExample;
import net.dlz.example.mapper.DistrictMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DistrictServiceImpl implements DistrictService{
    @Autowired
    private DistrictMapper districtMapper;
    @Override
    public List<District> listdistrict() {
        return districtMapper.selectByExample(new DistrictExample());
    }

    @Override
    public int deleteDistrictByPrimaryKey(String district_Id) {
        return districtMapper.deleteByPrimaryKey(district_Id);
    }

    @Override
    public District findDistrictByPrimaryKey(String district_Id) {
        return districtMapper.selectByPrimaryKey(district_Id);
    }


    @Override
    public int saveDistrict(District district){

        if (StringUtils.isNotBlank(district.getDistrictId()+"")){
            return districtMapper.updateByPrimaryKey(district);
        }else{
            return districtMapper.insert(district);
        }


    }

//    @Override
//    public List<District> selectDistrictTypeCount(String districtName) {
//        return districtMapper.selectDistrictTypeCount(districtName);
//    }
//
//    @Override
//    public List<District> findDistrictByName() {
//        return districtMapper.selectAllDistrict();
//    }

    @Override
    public List<District> selectAllDistrict() {
        return  districtMapper.selectAllDistrict();
    }

    @Override
    public List<District> selectDistrictTypeCount(String districtName) {
        return null;
    }

    @Override
    public List<District> findDistrictByName() {
        return null;
    }


}
